package com.flashcash.solu.view;

import android.content.Intent;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

import com.flashcash.kotlin.utils.FirebaseAnalyticsConstants;
import com.flashcash.kotlin.utils.FirebaseAnalyticsUtils;
import com.flashcash.solu.R;
import com.flashcash.solu.app.base.BaseActivity;
import com.flashcash.solu.bean.ProgressBean;
import com.flashcash.solu.common.FieldParams;
import com.flashcash.solu.utils.ACache;
import com.flashcash.solu.view.presenter.SplashActPresenter;
import com.flashcash.solu.view.presenter.SplashActPresenterImpl;
import com.flashcash.solu.view.presenter.SplashActView;

/**
 * 启动页
 * Created by milo on 17-2-8.
 */

public class SplashActivity extends BaseActivity<SplashActPresenter> implements SplashActView {
    private static final String TAG = "SplashActivity---";
    private ACache aCache;

    @Override
    protected void initBeforeSetContentView() {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        Log.e(TAG, getApplicationInfo().packageName);
    }

    @Override
    protected SplashActPresenter initPresenterImpl() {
        return new SplashActPresenterImpl();
    }


    @Override
    public int getLayoutResId() {
        return R.layout.activity_splash;
    }

    @Override
    public void init() {
        FirebaseAnalyticsUtils.INSTANCE.logEvent(FirebaseAnalyticsConstants.Event.ACT_OPEN, null);
        aCache = ACache.get(this);
        aCache.put(FieldParams.ACacheKeys.ACACHE_ADD_USER, "0");
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.requestDataAndJump();
    }

    /**
     * 请求四步认证完成状态
     *
     * @param progressBean
     */
    @Override
    public void updateCertifyStateSuccess(ProgressBean progressBean) {
        if (progressBean.isCompleted()) {//完成四步认证，跳转到MainActivity
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
        } else {//未完成四步认证，跳转到认证页面
            handlerUnFinishCertify(progressBean, true);
        }
//        handlerUnFinishCertify(progressBean,true);
        finish();
    }
}